package com.znn.dagger2demo.module;

import android.content.Context;
import android.location.LocationManager;

import com.google.gson.Gson;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * @author RANDY.ZHANG
 * @version 1.0
 * @company:
 * @date 16/8/8 16:24
 */
@Module
public class AppApplicationModule {
    private final Context context;

    public AppApplicationModule(Context context) {
        this.context=context;
    }

    //标示这个方法可以提供LocationManager
    @Provides
    @Singleton
    LocationManager provideLocationManager() {
        return (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    }

    @Provides
    @Singleton
    Gson provideGson(){//函数名可以不以provide开头
        return new Gson();
    }
}
